#ifndef LCD_BSP_H
#define LCD_BSP_H

#include "stdint.h"
#include "nrf_gpio.h"

#define LCD_SDA    31
#define LCD_WR     30
#define LCD_SCL    29       // LCD有RGB的SPI模式，使用SPI模式时RS脚用于LCD_SCL 
#define LCD_CS     22
#define LCD_RST    5
#define LCD_EN     7

#define TFT_LCD_SDA_OUTPUT()        do { NRF_GPIO->DIRSET = (1UL << LCD_SDA); } while(0)
#define TFT_LCD_WR_OUTPUT()         do { NRF_GPIO->DIRSET = (1UL << LCD_WR); } while(0)
#define TFT_LCD_SCL_OUTPUT()        do { NRF_GPIO->DIRSET = (1UL << LCD_SCL); } while(0)
#define TFT_LCD_CS_OUTPUT()         do { NRF_GPIO->DIRSET = (1UL << LCD_CS); } while(0)
#define TFT_LCD_RST_OUTPUT()        do { NRF_GPIO->DIRSET = (1UL << LCD_RST); } while(0)
#define TFT_LCD_EN_OUTPUT()         do { NRF_GPIO->DIRSET = (1UL << LCD_EN); } while(0)

#define TFT_LCD_SDA_HIGH()          do { NRF_GPIO->OUTSET = (1UL << LCD_SDA); } while(0)
#define TFT_LCD_SDA_LOW()           do { NRF_GPIO->OUTCLR = (1UL << LCD_SDA); } while(0)
#define TFT_LCD_WR_HIGH()           do { NRF_GPIO->OUTSET = (1UL << LCD_WR); } while(0)
#define TFT_LCD_WR_LOW()            do { NRF_GPIO->OUTCLR = (1UL << LCD_WR); } while(0)
#define TFT_LCD_SCL_HIGH()          do { NRF_GPIO->OUTSET = (1UL << LCD_SCL); } while(0)
#define TFT_LCD_SCL_LOW()           do { NRF_GPIO->OUTCLR = (1UL << LCD_SCL); } while(0)
#define TFT_LCD_CS_HIGH()           do { NRF_GPIO->OUTSET = (1UL << LCD_CS); } while(0)
#define TFT_LCD_CS_LOW()            do { NRF_GPIO->OUTCLR = (1UL << LCD_CS); } while(0)
#define TFT_LCD_RST_HIGH()          do { NRF_GPIO->OUTSET = (1UL << LCD_RST); } while(0)
#define TFT_LCD_RST_LOW()           do { NRF_GPIO->OUTCLR = (1UL << LCD_RST); } while(0)
#define TFT_LCD_EN_HIGH()           do { NRF_GPIO->OUTSET = (1UL << LCD_EN); } while(0)
#define TFT_LCD_EN_LOW()            do { NRF_GPIO->OUTCLR = (1UL << LCD_EN); } while(0)

void  Lcd_WriteIndex2(uint8_t comm);

void  Lcd_WriteData2(uint8_t Data);

void Lcd_SetRegion(unsigned int x_start,unsigned int y_start,unsigned int x_end,unsigned int y_end);

void  LCD_WriteData_16Bit(unsigned int Data);

#endif //LCD_BSP_H